<?php
$path = $mosConfig_live_site."/uploads/content";

if ($task == 'blogsection'){
	$sql = "SELECT title FROM #__sections WHERE id=".$id;
	$where = " AND sectionid=".$id;
}	
if ($task == 'blogcategory'){
	$sql = "SELECT title FROM #__categories WHERE id=".$id;
	
	$sql = "select * from #__categories where parent_id=".$id;
	$database->setQuery($sql);
	$lsRows = $database->loadObjectList();
	if (count($lsRows)>0){
		$arr = "(".$id.",";
		for ($i=0; $i<count($lsRows); $i++){
			if ($i==(count($lsRows)-1)){
				$str = "";
			}else{
				$str = ",";
			}
			$arr .= $lsRows[$i]->id.$str;
		}
		$arr .= ")";
		//echo $arr;
		$where = " AND catid IN".$arr;
	}else{
		$where = " AND catid=".$id;
	}
}	
	
$database->setQuery($sql);
$database->loadObject($nameVip);

//show VIP
$sql = "SELECT id,title,title_alias,thumbnailImage,mediumImage,largeImage,price,price_giam,giam_gia,muc_giam,introtext"
		."\n FROM #__content"
		."\n WHERE state=1 AND vip=1".$where." ORDER BY ordering ASC, id DESC";
$database->setQuery( $sql );
$lsVip = $database->loadObjectlist();
$linkTopten = sefRelToAbs("index.php?option=com_content&task=view&id=".$lsVip[0]->id).$lsVip[0]->title_alias;
if (count($lsVip)>9){
?>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
	$('#load_me').load('<?php echo $mosConfig_live_site;?>/ajax/vip_response.php?task=<?php echo $task;?>&id=<?php echo $id;?>').fadeIn("slow");
}, 10000); // autorefresh the content of the div after
//every 10000 milliseconds(10sec)
</script>
<?php 
}
if (count($lsVip)>0){
?>
<div class="w_box_show_content title-css3">
	<div class="w_title_website">
		<div class="w_show_title_website">Tin Vip <?php echo $nameVip->title;?></div>
		<div class="clearfix"></div>
		<div class="w_show_content border-shadow">
			<div class="w_product_topten">
				<a href="<?php echo $linkTopten;?>">
					<img src="<?php echo $path;?>/large/<?php echo $lsVip[0]->largeImage;?>" border="0" />
				</a>
				<div class="w_title_topten">
					<a href="<?php echo $linkTopten;?>"><?php echo $lsVip[0]->title;?></a>
					<p><?php echo $lsVip[0]->introtext;?></p>
				</div>
				<?php if ($lsVip[0]->giam_gia == 0){?>
				<div class="w_price_topten">Giá bán : <?php echo number_format($lsVip[0]->price,0,".",",");?> VNĐ</div>
				<?php }else{?>
				<div class="w_price_topten" style="line-height: 25px; height: 80px; text-align: left;">
					<span style="padding-left:5px; color:#000; text-decoration: line-through;">Giá cũ: <?php echo number_format($lsVip[0]->price,0,".",",");?> VNĐ</span>
					<div class="clearfix"></div>
					<span style="padding-left:5px;">Giá bán: <?php echo number_format($lsVip[0]->price_giam,0,".",",");?> VNĐ</span>
					<div class="clearfix"></div>
					<span style="padding-left:5px; color:yellow;">Mức giảm: <?php echo number_format($lsVip[0]->muc_giam,0,".",",");?> VNĐ</span>
				</div>
				<?php }?>
			</div>
			<div class="w_product_other" id="load_me">
			<?php
			for ($i=1; $i<count($lsVip); $i++){
				$linkurl = sefRelToAbs("index.php?option=com_content&task=view&id=".$lsVip[$i]->id).$lsVip[$i]->title_alias;
				?>
				<div class="w_lsProduct style-product-css3">
					<a href="<?php echo $linkurl;?>">
						<?php if ($lsVip[$i]->muc_giam == 0){?>
						<img src="<?php echo $path;?>/medium/<?php echo $lsVip[$i]->mediumImage;?>" border="0" />
						<?php }else{?>
						<img src="<?php echo $path;?>/thumbnail/<?php echo $lsVip[$i]->thumbnailImage;?>" style="width:70px;" border="0" />
						<?php }?>
					</a>
					<div class="clearfix"></div>
					<a href="<?php echo $linkurl;?>"><?php echo $lsVip[$i]->title;?></a><br />
					<?php if ($lsVip[$i]->giam_gia == 0){?>
					<span><?php echo number_format($lsVip[$i]->price,0,".",",");?> VNĐ</span>
					<?php }else{?>
					<span style="font-size:11px;">Giá bán: <?php echo number_format($lsVip[$i]->price_giam,0,".",",");?> VNĐ</span>
					<div class="clearfix"></div>
					<span style="font-size:11px; text-decoration: line-through; color:#707070;">Giá cũ: <?php echo number_format($lsVip[$i]->price,0,".",",");?> VNĐ</span>
					<?php }?>
					<?php if ($lsVip[$i]->muc_giam > 0){?>
					<div class="muc_giam">Giảm: <?php echo number_format($lsVip[$i]->muc_giam,0,".",",");?> VNĐ</div>
					<?php }?>
				</div>
				<?php	
			} 
			?>
			</div>
		</div>
	</div>
</div>	
<div class="clearfix"></div>
<?php 
}
?>